package fr.expdev.bndd;

import fr.expdev.bndd.data.Post;
import android.content.Context;
import android.graphics.Color;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class PostView extends LinearLayout {

	public PostView(Context context, Post post) {
		super(context);
		
		setOrientation(HORIZONTAL);

		/* Image View */
		ImageView typeImage = new ImageView(context);
		LinearLayout.LayoutParams typeParams = new LayoutParams(50, 50);
		typeImage.setImageResource(post.getTypeRessource());
		
		/* Title Text View */
		TextView titleTV = new TextView(context);
		LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 50);
		
		titleTV.setText(post.getTitle());
		titleTV.setTextSize(16f);
		titleTV.setTextColor(Color.WHITE);
		titleParams.setMargins(1, 1, 1, 1);

		/* Detail Text View */
		/*TextView detailTV = new TextView(context);
		LinearLayout.LayoutParams detailsParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 20);
		
		detailTV.setText(post.getDetail());
		detailTV.setTextSize(12f);
		detailTV.setTextColor(Color.WHITE);
		detailsParams.setMargins(1, 1, 1, 1);*/

		/* Sub Layout (title + detail) */
		LinearLayout subLayout = new LinearLayout(context);
		LinearLayout.LayoutParams subLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		
		subLayout.setOrientation(VERTICAL);
		subLayoutParams.setMargins(1, 1, 1, 1);
		
		subLayout.addView(titleTV, titleParams);
		//subLayout.addView(detailTV, detailsParams);
		
		this.addView(typeImage, typeParams);
		this.addView(subLayout, subLayoutParams);
	}

}
